require(['./config'], () => {
  require(['header', 'footer', 'cookie'], () => {
    class register {
      constructor() {
        this.getUser()
      }
      getUser () {
        $('.regis').on('click', function () {
          //用localStorage来模拟存储
          let username = $('.user').val()
          let password = $('.psw').val()
          let em = $('.emil').val()
          var uPattern = /^[a-zA-Z0-9_-]{4,16}$/;
          var pPattern = /^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$/;
          var un=uPattern.test(username)
          var up = pPattern.test(password)
          console.log(up)
          if(un){
            if(up){
              let userInfo = { username, password, em }
              //先把本地存储取出来
              var userList = localStorage.getItem('userList')
              if(userList){
                userList = JSON.parse(userList)
                userList.push(userInfo)
                localStorage.setItem('userList',JSON.stringify(userList))
              }else{
                //第一次存
                var arr = [userInfo]
                localStorage.setItem('userList',JSON.stringify(arr))
              }
              alert('注册成功')
              window.location.href = '/html/login.html'

            }else{
              alert('密码最少6位，包括至少一个大写字母，一个小写字母，一个数字，一个特殊字符')
            }
          }else{
            alert('用户名为4到16位，可以包含字母，数字，下划线，减号')
          }
          
         
         
        })
      }
    }
    new register()
  })
})